<?PHP

	include("../includes/configPages.php");
	
	if($_SESSION['logged_in']==true){
	
		/* registration variables */
		$variableStack['profileTitle'] = "Your profile";
		$result = $users->getUser($db, $_SESSION["uid"]);
		if($result){
			while($row = mysql_fetch_object($result)){
				$variableStack['avatar'] = stripslashes($row->user_avatar);
				$variableStack['username'] = stripslashes($row->username);
				$variableStack['email'] = stripslashes($row->email);
				$variableStack['rname'] = stripslashes($row->rname);
				$variableStack['age'] = stripslashes($row->age);
				$variableStack['location'] = stripslashes($row->location);
				$variableStack['occupation'] = stripslashes($row->occupation);
				$variableStack['interests'] = stripslashes($row->interests);
				
				$variableStack['contact_msn']=stripslashes($row->contact_msn);
				$variableStack['contact_icq']=stripslashes($row->contact_icq);
				$variableStack['contact_jabber']=stripslashes($row->contact_jabber);
				$variableStack['contact_gchat']=stripslashes($row->contact_gchat);
				$variableStack['contact_yim']=stripslashes($row->contact_yim);
				$variableStack['contact_website']=stripslashes($row->contact_website);
			}
		
			$html = file_get_contents('../styles/'.$activeStyle.'/t/profile.html');	
			
			$sigResult = $users->getSignature($db, $_SESSION["uid"]);
			$variableStack['signature'] = mysql_result($sigResult,0,'sig_tags');
			
			/* custom foelds */
			$customFieldsAll = $users->getAllCustomFields($db);
			$variableStack['customfields'] = "";
			$htmlField = file_get_contents('../styles/'.$activeStyle.'/t/profile-field.html');			
			if($customFieldsAll){
				while($row = mysql_fetch_object($customFieldsAll)){
					if($row->field_enabled==1){
						$fieldVariableStack['text'] = $row->field_name;
						$fieldVariableStack['control'] = $users->buildControl($db, $row->field_id, $_SESSION['uid']);
						$variableStack['customfields'] .= parseHtml($htmlField, $fieldVariableStack);	
					}
				}
			}
			
			echo parseHtml($html, $variableStack);	
		}
		
	} else {

		echo "<script>fetchPage('login' ,null)</script>";
		
	}

?>